<?php

/**
 * Abstract SmugMug entity
 */
abstract class str_SmugMugEntity {
    
    protected $_entityData = null;
    protected $_phpSmug = null;
    
    public function __construct(Array $data, phpSmug $phpSmug) {
        if ($data !== null) {
            $this->setData($data);
        }
        
        $this->_setPhpSmug($phpSmug);
    }
    
    public function getData() {
        return $this->_entityData;
    }
    
    public function setData(Array $data) {
        $this->_entityData = $data;
    }
    
    public function getId() {
        if ($this->isNullObject()) {
            return 0;
        }
        
        $data = $this->getData();
        return $data['id'];
    }
    
    public function getKey() {
        if ($this->isNullObject()) {
            return '';
        }
        
        $data = $this->getData();
        return $data['Key'];
    }
    
    protected function _getPhpSmug() {
        return $this->_phpSmug;
    }
    
    protected function _setPhpSmug(phpSmug $phpSmug) {
        $this->_phpSmug = $phpSmug;
    }

    protected function isNullObject() {
        return $this->_entityData === null;
    }
}